package com.quicksignin.service.impl;

import com.quicksignin.common.ServerResponse;
import com.quicksignin.dao.SignInMapper;
import com.quicksignin.pojo.SignIn;
import com.quicksignin.service.ISignInService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by GHD on 2018/9/29.
 */
@Service
public class SignInServiceImpl implements ISignInService {

    @Autowired
    private SignInMapper signInMapper;

    @Override
    public ServerResponse<SignIn> signIn(String stuId,String name, String ip,String teacherName) {
        SignIn signIn = new SignIn();
        int ipResult = signInMapper.ipContrast(ip);
        signIn.setStuId(stuId);
        signIn.setIpAddr(ip);
        signIn.setName(name);
        signIn.setTeacherName(teacherName);
        int result = signInMapper.insert(signIn);
        if (result == 0) {
            return ServerResponse.createByErrorMessage("签到失败");
        }
        return ServerResponse.createBySuccessMessage("签到成功");
    }
}

